#set(modelClass = cls.getModuleClass("model"))
#set(tableConfig = cls.tableConfig)
#set(modelVar = cls.getModuleVar("model"))
package #(parentPackage);

import #(cls.getModulePackage("model"));
import #(cls.getModulePackage("service"));
import com.goldsyear.solon.common.core.model.Ret;
import #(cls.superClass);
import com.goldsyear.solon.web.model.query.QPage;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.noear.solon.annotation.*;


/**
 * #(cls.comment) Controller 控制层
 *
 * @author #(author)
 * @since #(since)
 */
@Component(tag = "adminApi")
@Mapping("/#(cls.mappingPath)")
@Slf4j
public class #(cls.moduleClass) extends #(cls.superClassSimple) {
  @Inject private #(cls.getModuleClass("service")) service;

  @Post
  @Mapping("create")
  public Ret create(@Body #(modelClass) #(modelVar)) {
    return Ret.okWithData(service.create#(modelClass)(#(modelVar)));
  }

  @Post
  @Put
  @Mapping("update")
  public Ret update(@Body #(modelClass) #(modelVar)) {
    return Ret.okWithData(service.update#(modelClass)(#(modelVar)));
  }

  @Get
  @Mapping("get")
  public Ret get(@Param #(cls.pkClass) #(cls.pk)) {
    return Ret.okWithData(service.get#(modelClass)(#(cls.pk)));
  }

  @Post
  @Delete
  @Mapping("delete")
  public Ret delete(@Param #(cls.pkClass) #(cls.pk)) {
    return Ret.okWithData(service.delete#(modelClass)(#(cls.pk)));
  }

  @Post
  @Delete
  @Mapping("batchDel")
  public Ret batchDel(@Param List<#(cls.pkClass)> #(cls.pk)s) {
    return Ret.okWithData(service.batchDel#(modelClass)(#(cls.pk)s));
  }

  @Get
  @Mapping("paginate")
  public Ret paginate(QPage qPage) {
    #(modelClass) #(modelVar) = getBean(#(modelClass).class);
    return Ret.okWithData(service.paginate#(modelClass)(qPage, #(modelVar)));
  }

  @Get
  @Mapping("list")
  public Ret list() {
    #(modelClass) #(modelVar) = getBean(#(modelClass).class);
    return Ret.okWithData(service.list#(modelClass)(#(modelVar)));
  }

#if(tableConfig.enableSimpleList)

  @Get
  @Mapping("simpleList")
  public Ret simpleList() {
    #(modelClass) #(modelVar) = getBean(#(modelClass).class);
    return Ret.okWithData(service.simpleList#(modelClass)(#(modelVar)));
  }
#end
#if(tableConfig.enableOptions)

  @Get
  @Mapping("options")
  public Ret options() {
    #(modelClass) #(modelVar) = getBean(#(modelClass).class);

    return Ret.okWithData(service.options#(modelClass)(dictCode));
  }
#end
}